package com.better.backend.mqReceiverService.calType.listener;

import com.alibaba.fastjson.JSONObject;
import com.better.backend.mqReceiverService.calType.calService.CalService;
import com.better.backend.mqReceiverService.examReceiver.model.ExamModel;
import com.better.backend.mqReceiverService.examReceiver.repository.ExamRepsitory;
import com.better.common.mq.MqTopic;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author xiaq
 * 消息接收 发布成绩
 * @create 2017-09-23 12:01
 **/
@Component
public class CalReceiver {
    @Autowired
    private CalService calService;
    private static Log log = LogFactory.getLog(CalReceiver.class);
    @RabbitListener(queues = MqTopic.ZXY_CACULATE)
    public void process(Message examModel) {
        String examId = new String(examModel.getBody());
        log.info("接收需要计算的考试ID："+examId);
        calService.calculate(examId);
    }
}
